package com.cuoyi.coupon.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cuoyi.coupon.mall.common.BusinessException;
import com.cuoyi.coupon.mall.mybatis.entity.User;
import com.cuoyi.coupon.mall.mybatis.mapper.UserMapper;
import com.cuoyi.coupon.mall.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Mybatis Plus Generator
 * @since 2022-03-04 10:02:25
 */
@Slf4j
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Value("${login.username}")
    private String loginUsername;

    @Value("${login.password}")
    private String loginPassword;

    @Override
    public User findById(Long id) {
        log.info("findById......" + id);
        return this.getById(id);
    }

    @Override
    public String getPassword(String name) {
        if (loginUsername.equals(name)) {
            return loginPassword;
        }
        return "";
    }

    @Override
    public boolean verifyLoginUser(String username, String password) {
        if (!loginUsername.equals(username)) {
            return false;
        }
        if (!loginPassword.equals(password)) {
            return false;
        }
        return true;
    }
}
